package com.yyds.blackmagic.service.impl;

import com.yyds.blackmagic.entity.User;
import com.yyds.blackmagic.mapper.UserMapper;
import com.yyds.blackmagic.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author ccc
 * @Date 2021/12/13
 * @Descripton
 */


@Service
public class UserServiceImpl implements UserService {
    @Resource
    private UserMapper userMapper;

    @Override
    public List<User> findAll() {
        List<User> users = userMapper.selectAll();
        return users;
    }

    @Override
    public User findByUsername(String username) {
        User user = userMapper.selectByUsername(username);
        return user;
    }

    @Override
    public User addUser(User user) {
        int i = userMapper.insertUser(user);
        return user;
    }

    @Override
    public User updateUser(User user) {
        int i = userMapper.updateUser(user);
        return user;
    }

    @Override
    public boolean deleteUser(int id) {
        int i = userMapper.deleteUser(id);
        if(i>0){
            return true;
        }
        return false;
    }
}
